package com.example.dryclean_admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.dryclean_admin.entity.Orderlog;
import com.example.dryclean_admin.entity.ProgressStage;
import com.example.dryclean_admin.mapper.OrderlogMapper;
import com.example.dryclean_admin.mapper.ProgressStageMapper;
import com.example.dryclean_admin.service.IProgressStageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 进度阶段服务实现类
 * </p>
 *
 * @author 你的名字
 * @since 2024-01-01
 */
@Service
public class ProgressStageServiceImpl extends ServiceImpl<ProgressStageMapper, ProgressStage> implements IProgressStageService {

    @Autowired
    private ProgressStageMapper progressStageMapper;
    @Autowired
    private OrderlogMapper orderlogMapper;
    @Override
    public List<ProgressStage> list2() {
        LambdaQueryWrapper<ProgressStage> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByAsc(ProgressStage::getId);
        List<ProgressStage> list = progressStageMapper.selectList(wrapper);
        list.forEach(progressStage -> {
            LambdaQueryWrapper<Orderlog> orderlogWrapper = new LambdaQueryWrapper<>();
            orderlogWrapper.eq(Orderlog::getOrderid, progressStage.getId());
            orderlogWrapper.orderByAsc(Orderlog::getProcessid);
            List<Orderlog> orderLogs = orderlogMapper.selectList(orderlogWrapper);
            progressStage.setOrderLogs(orderLogs);
        });
        return list;
    }
}
